package com.sxj.corejava.code15_反射;

/**
 * @author 石小俊
 */
public class Test01_获取Class对象 {

    public static void main(String[] args) throws ClassNotFoundException {
        // 方式一:调用类的class属性
        Class c1 = User.class;
        System.out.println(c1);

        // 方式二:调用类的getClass方法
        User user = new User();
        Class c2 = user.getClass();
        System.out.println(c2);

        // 方式三:通过Class类提供的静态方法forName获取
        Class c3 = Class.forName("com.sxj.corejava.code15_反射.User");
        System.out.println(c3);

        System.out.println(c1 == c2);
        System.out.println(c2 == c3);
    }

}
